package com.golddaymicromall.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.golddaymicromall.activity.R;
import com.golddaymicromall.bean.OnlineRemittanceInfo;
import com.golddaymicromall.util.DateFormatUtils;

import java.util.List;

/**
 * Created by 王立强 on 2016/3/7 0007.
 */
public class OnlineRemittanceAdapter extends BaseAdapter {
    private List<OnlineRemittanceInfo> list;
    private Context ctx;
    LayoutInflater layoutinflater;

    public OnlineRemittanceAdapter(List<OnlineRemittanceInfo> list, Context ctx) {
        this.list = list;
        this.ctx = ctx;
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return getItem(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        final  ViewHolder hold;
        View view = convertView;
        if(view == null){
            hold = new ViewHolder();
            layoutinflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            view = layoutinflater.inflate(R.layout.item_onlineremittance, null);
            hold.mOnline_OrderNo = (TextView) view.findViewById(R.id.online_orderNo);
            hold.mOnline_Status = (TextView) view.findViewById(R.id.online_status);
            hold.mOnline_Date = (TextView) view.findViewById(R.id.online_date);
            hold.mOnline_Money = (TextView) view.findViewById(R.id.online_Money);
            hold.mOnline_CardType = (TextView) view.findViewById(R.id.online_cardtype);
            view.setTag(hold);
        }else{
            hold = (ViewHolder) view.getTag();
        }
        hold.mOnline_OrderNo.setText(list.get(position).getBillno());
        hold.mOnline_Date.setText(new DateFormatUtils().dateFormat(list.get(position).getCreatedate().toString()));
        hold.mOnline_Money.setText(list.get(position).getAmount().toString());
        hold.mOnline_Status.setText(list.get(position).getSucc());
        hold.mOnline_CardType.setText(list.get(position).getRmb());
        return view;
    }

    private class ViewHolder{
        TextView mOnline_OrderNo;
        TextView mOnline_Date;
        TextView mOnline_Status;
        TextView mOnline_Money;
        TextView mOnline_CardType;
    }
}
